package com.ly.lypopupwindowdemo.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by liying on 2017/7/13.
 */

public class AdapterViewPager extends PagerAdapter {
    private List<View> lists;

    public AdapterViewPager(List<View> lists) {
        this.lists = lists;
    }

    /**
     * 以下四个方法必须实现
     * @return
     */
    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(lists.get(position));
        return lists.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(lists.get(position));

    }
}
